/**
 * 员工月度绩效申报
 */
/**
 * 表单自定义控制器
 */
app.controller('btnCtrl', ['$scope', '$http', BtnController]);
function BtnController($scope, $http) {
	$scope.bindBtn = function(event) {
		switch(event){
			case 'event-to-add': // 新增
			{
				var listUkey = [];
				for(var i=0;i<$scope.subGrid.sonlist.length;i++){
					var data = $scope.subGrid.sonlist[i];
					listUkey.push(data.monthPerformanceId);
				}
				$scope.showModalCheckBox('TB_UserMonthPerformance','id',listUkey );
				//layui.YsModal.init({modalKey: 'TB_UserMonthPerformance', type: 'checkbox', uniqueKey: 'id', parentObj: t.c.subGridObj, selectedData: selectedDatas, extraData:{}, conditionsDefault: []});
				break;
			}
			case 'event-to-delete': // 删除选中数据
			{
				$scope.subGrid.deleteBatch();
				break;
			}
		};
	}

}



/*
 * 子列表控制器
 */
app.controller('subGridCtrl', ['$scope', '$http', function SubGridController($scope, $http){
	/*
	 * 复选框回调
	 */
	$scope.checkbox.afterSelectDatas = function(rowsSelected) {
		for (var i = 0; i < rowsSelected.length; i++) {
			var obj = rowsSelected[i];
			var rowCurrent = {};
			rowCurrent.id = null;
			rowCurrent.monthPerformanceId = obj.id;

			rowCurrent.pointMonth = obj.pointMonth;//评定年月
			rowCurrent.userName = obj.userName;//工号/姓名
			rowCurrent.userState = obj.userState;//员工状态
			rowCurrent.deptName = obj.deptName;//部门
			rowCurrent.orgName = obj.orgName;//所属公司
			rowCurrent.rank = obj.rank;//岗位职级
			rowCurrent.type = obj.type;//岗位工种

			rowCurrent.hrPerformancePoint = 0.00;//人事绩效评分
			rowCurrent.hrPerformanceContent = '';//人事绩效内容
			rowCurrent.jobBonus = obj.jobBonus?obj.jobBonus:0.00;//岗位提奖
			rowCurrent.jobBonusExplain = obj.jobBonusExplain?obj.jobBonusExplain:'';//岗位提奖说明
			//过滤已选择的
			if($scope.subGrid.sonlist!=null && $scope.subGrid.sonlist.length>0){
				var isChoosed = false;
				for (var j = 0; j < $scope.subGrid.sonlist.length; j++) {
					if($scope.subGrid.sonlist[j].monthPerformanceId == obj.id){
						isChoosed = true;
					}
				}
			}
			if(!isChoosed){
				$scope.subGrid.sonlist.push(rowCurrent);
			}
		}
	}
}]);



